package com.chif.mapreduce.ReduceJoin;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class TableDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        //指定hadoop运行时在本地的临时工作目录
        conf.set("hadoop.tmp.dir", "D:/tmp/mapreduce_tmp_cache");

        Job job = Job.getInstance(conf);

        job.setJarByClass(TableDriver.class);
        job.setMapperClass(TableMapper.class);
        job.setReducerClass(TableReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(TableBean.class);

        job.setOutputKeyClass(TableBean.class);
        job.setOutputValueClass(NullWritable.class);

        FileInputFormat.setInputPaths(job,new Path("C:\\Users\\Chef Liu\\Desktop\\Big\\hadoop\\input2"));
        FileOutputFormat.setOutputPath(job,new Path("C:\\Users\\Chef Liu\\Desktop\\Big\\hadoop\\output"));

        boolean b = job.waitForCompletion(true);
        System.exit(b?0:1);


    }
}
